#define LOG_FATAL    (1)
#define LOG_ERR      (2)
#define LOG_WARN     (3)
#define LOG_INFO     (4)
#define LOG_DBG      (5)

#define DEBUG_LEVEL  (4)
#define DBGSTREAM stderr

#define LOG(level, ...) do {  \
                            if (level <= DEBUG_LEVEL) { \
                                fprintf(DBGSTREAM,"%s:%d:", __FILE__, __LINE__); \
                                fprintf(DBGSTREAM, __VA_ARGS__); \
                                fprintf(DBGSTREAM, "\n"); \
                                fflush(DBGSTREAM); \
                            } \
                        } while (0)
